package org.rcgwt.client.ui.calendar.resources;

import java.util.Date;
import java.util.List;

import org.rcgwt.client.ui.calendar.i18n.CalendarLiteral;
import org.rcgwt.client.ui.calendar.i18n.CalendarUtils;
import org.rcgwt.client.ui.calendar.model.impl.Event;
import org.rcgwt.client.ui.calendar.model.impl.EventFrequency;
import org.rcgwt.client.ui.calendar.model.impl.EventType;

import com.google.gwt.i18n.client.DateTimeFormat;

@SuppressWarnings("deprecation")
public class ToolTipProvider {

	private static String[] days = CalendarUtils.getDays();
	
	public static String getShortToolTipForEvent(Event e) {
		DateTimeFormat format = DateTimeFormat.getFormat(CalendarLiteral
				.getDateTimeLitteral());

		EventType type = e.getEventType();
		EventFrequency freq = e.getFrequency();
		String frequency = " : " + freq.name().toLowerCase();

		String title = e.getTitle();

		Date startTime = e.getStartTime();
		Date endTime = e.getEndTime();

		if (freq == EventFrequency.NONE) {
			frequency = "";
		}
		return "\n|" + type.name() + "| (" + format.format(startTime) + " to "
				+ format.format(endTime) + frequency + ") --> [" + title + "]";
	}

	public static String getLongToolTipForEvent(Event e) {
		Date startTime = e.getStartTime();
		Date endTime = e.getEndTime();

		String title = e.getTitle();
		String content = e.getContent();

		String place = e.getPlace();
		List<String> participants = e.getParticipants();

		return "(" + startTime + " to " + endTime + ")[" + title + "] \n "
				+ content + " (at " + place + " with " + participants + " )";
	}

	public static String getToolTipForDate(int year, int month, int date) {
		Date d = new Date(year - 1900, month, date);

		String day = days[d.getDay()];
		if (month < 0 || month > 11) {
			return null;
		}
		return day + " " + date + " " + CalendarUtils.getMonths()[month]
				+ " " + year;
	}
}
